<template>
    <div>
        <h1>理疗新增</h1>
    </div>
    <table class="table">
        <tbody>
            <tr>
                <td>理疗名称</td>
                <td>
                    <input type="text" v-model="data.HelthName">
                </td>
            </tr>
            <tr>
                <td>金额</td>
                <td>
                    <input type="text" v-model="data.Money">
                </td>
            </tr>
            <tr>
                <td>人数</td>
                <td>
                    <input type="text" v-model="data.People">
                </td>
            </tr>
            <tr>
                <td>时长</td>
                <td>
                    <input type="text" v-model="data.Hour">
                </td>
            </tr>
            <tr>
                <td>项目说明</td>
                <td>
                    <textarea v-model="data.Xm"></textarea>
                </td>
            </tr>
            <tr>
                <td>状态</td>
                <td>
                    <select v-model="data.State">
                        <option value="0">请选择状态</option>
                        <option v-for="d in statelist" :value="d.id">{{d.name}}</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" value="新增" @click="add">
                </td>
            </tr>
        </tbody>
    </table>
</template>

<script setup lang="ts">
import axios from 'axios';
import {ref,onMounted} from 'vue';
import { useRouter } from 'vue-router';
const router=useRouter();
const statelist=([{id:1,name:'启用'},{id:2,name:'禁用'}])
const data=ref({
     "Id": 0,
  "HelthName": "",
  "Bh": "",
  "Money": 0,
  "People": 0,
  "Hour": 0,
  "Xm": "",
  "State": 0
})
const add=()=>{
    if(data.value.HelthName=="")
    {
        alert('理疗名称不能为空');
        return;
    }
    if(data.value.Money==0)
    {
        alert('金额不能为空');
        return;
    }

    if(data.value.People==0)
    {
        alert('人数不能为空');
        return;
    }
    if(data.value.Hour==0)
    {
        alert('时长不能为空');
        return;
    }
    if(data.value.Xm=="")
    {
        alert('项目说明不能为空');
        return;
    }
    if(data.value.State==0)
    {
        alert('状态不能为空');
        return;
    }
    axios.post("/api/Health/AddHeath",data.value).then(res=>{
        if(res.data>0)
        {
            alert('新增成功');
            router.push('/show');
        }
        else
        {
            alert('新增失败');
            return;
        }
    })
}





</script>

<style scoped>

</style>